package etude.collecteur.impl;

import java.nio.charset.Charset;

import etude.collecteur.Collector;

/**
 * Bouchon de Collector.
 * 
 * <p>
 * Celui-ci simule le résultat de l'appel au Collector.
 * </p>
 * 
 * @author Sebastien
 * 
 */
public class MockCollector implements Collector {

	/**
	 * L'encoding UTF-8 de la réponse.
	 */
	private static final Charset UTF8 = Charset.forName("UTF-8");

	/**
	 * Le contenu de la réponse.
	 */
	private static final String TEXT = "<?xml version=\"1.0\"?>\n"
			+ "<!DOCTYPE html\n"
			+ "    PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"\n"
			+ "    \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n"
			+ "<html>\n"
			+ "<head>\n"
			+ "<title>Operation Results</title>\n"
			+ "<link rel=\"stylesheet\" href=\"style_master.css\" type=\"text/css\" />\n"
			+ "<meta http-equiv=\"cache-control\" content=\"no-cache\" />\n"
			+ "</head>\n\n"
			+ "<body leftmargin=\"10\" rightmargin=\"10\" topmargin=\"10\">\n"
			+ "<table width=\"100%\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\" align=\"center\">\n"
			+ " <tr>\n"
			+ "  <td height=\"105\" align=\"center\"><h1>JMX MBean Operation View</h1>A82A004500</td>\n"
			+ "  <td height=\"105\" align=\"center\" width=\"300\">\n"
			+ "    <p>\n"
			+ "      <input type=\"button\" value=\"Back to Agent\" onClick=\"javascript:location='HtmlAdaptor?action=displayMBeans'\"/>\n"
			+ "      <input type=\"button\" value=\"Back to MBean\" onClick=\"javascript:location='HtmlAdaptor?action=inspectMBean&amp;name=jboss.jca%3Aservice%3DManagedConnectionPool%2Cname%3Deis%2FXUConnectionFactory'\"/>\n"
			+ "    </p>\n"
			+ "    <p>\n"
			+ "    <input type='button' onClick=\"location='HtmlAdaptor?action=invokeOpByName&amp;name=jboss.jca%3Aservice%3DManagedConnectionPool%2Cname%3Deis%2FXUConnectionFactory&amp;methodName=listFormattedSubPoolStatistics'\" value='Reinvoke MBean Operation'/>\n"
			+ "    </p>\n" + "  </td>\n" + " </tr>\n" + "</table>\n"
			+ "<pre>\n" + "Sub Pool Statistics:\n" + "Sub Pool Count: 9\n"
			+ "------------------------------------------------------\n"
			+ "Available Connections Count:50\n"
			+ "Max Connections In Use Count:1\n"
			+ "Connections Destroyed Count:0\n"
			+ "Connections In Use Count:0\n" + "Total Block Time:0\n"
			+ "Average Block Time For Sub Pool:0\n"
			+ "Maximum Wait Time For Sub Pool:0\n" + "Total Timed Out:0\n"
			+ "------------------------------------------------------\n"
			+ "Available Connections Count: 50\n"
			+ "Max Connections In Use Count:1\n"
			+ "Connections Destroyed Count:0\n"
			+ "Connections In Use Count:0\n" + "Total Block Time:0\n"
			+ "Average Block Time For Sub Pool:0\n"
			+ "Maximum Wait Time For Sub Pool:0\n" + "Total Timed Out:0\n"
			+ "------------------------------------------------------\n"
			+ "Available Connections Count: 50\n"
			+ "Max Connections In Use Count:1\n"
			+ "Connections Destroyed Count:0\n"
			+ "Connections In Use Count:0\n" + "Total Block Time:0\n"
			+ "Average Block Time For Sub Pool:0\n"
			+ "Maximum Wait Time For Sub Pool:0\n" + "Total Timed Out:0\n"
			+ "------------------------------------------------------\n"
			+ "Available Connections Count: 50\n"
			+ "Max Connections In Use Count:1\n"
			+ "Connections Destroyed Count:0\n"
			+ "Connections In Use Count:0\n" + "Total Block Time:0\n"
			+ "Average Block Time For Sub Pool:0\n"
			+ "Maximum Wait Time For Sub Pool:0\n" + "Total Timed Out:0\n"
			+ "------------------------------------------------------\n"
			+ "Available Connections Count: 50\n"
			+ "Max Connections In Use Count:1\n"
			+ "Connections Destroyed Count:0\n"
			+ "Connections In Use Count:0\n" + "Total Block Time:0\n"
			+ "Average Block Time For Sub Pool:0\n"
			+ "Maximum Wait Time For Sub Pool:0\n" + "Total Timed Out:0\n"
			+ "------------------------------------------------------\n"
			+ "Available Connections Count: 50\n"
			+ "Max Connections In Use Count:1\n"
			+ "Connections Destroyed Count:0\n"
			+ "Connections In Use Count:0\n" + "Total Block Time:0\n"
			+ "Average Block Time For Sub Pool:0\n"
			+ "Maximum Wait Time For Sub Pool:0\n" + "Total Timed Out:0\n"
			+ "------------------------------------------------------\n"
			+ "Available Connections Count: 50\n"
			+ "Max Connections In Use Count:1\n"
			+ "Connections Destroyed Count:0\n"
			+ "Connections In Use Count:0\n" + "Total Block Time:0\n"
			+ "Average Block Time For Sub Pool:0\n"
			+ "Maximum Wait Time For Sub Pool:0\n" + "Total Timed Out:0\n"
			+ "------------------------------------------------------\n"
			+ "Available Connections Count: 50\n"
			+ "Max Connections In Use Count:1\n"
			+ "Connections Destroyed Count:0\n"
			+ "Connections In Use Count:0\n" + "Total Block Time:0\n"
			+ "Average Block Time For Sub Pool:0\n"
			+ "Maximum Wait Time For Sub Pool:0\n" + "Total Timed Out:0\n"
			+ "------------------------------------------------------\n"
			+ "Available Connections Count: 50\n"
			+ "Max Connections In Use Count:1\n"
			+ "Connections Destroyed Count:0\n"
			+ "Connections In Use Count:0\n" + "Total Block Time:0\n"
			+ "Average Block Time For Sub Pool:0\n"
			+ "Maximum Wait Time For Sub Pool:0\n" + "Total Timed Out:0\n"
			+ "------------------------------------------------------\n"
			+ "</pre>\n" + "</body>\n" + "</html>";

	@Override
	public byte[] collect() {
		return TEXT.getBytes(UTF8);
	}

}
